home *** CD-ROM | disk | FTP | other *** search
- //sample texture, and make a tiny part of it "shine" based on distance froma given point
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //cloud sampler
- sampler2D sampTex;
-
- //shader input
- struct PS_INPUT
- {
- float3 Pos : TEXCOORD1;
- float2 Tex0 : TEXCOORD0;
- float4 Color : COLOR;
- };
-
- //things within a certain distance of this will "shine"
- float2 point;
-
- //distance from point at which shine occurs
- float tarDist;
-
- //shader code
- float4 PShader(PS_INPUT In) : COLOR
- {
- //sample textutes
- float4 texclr=tex2D(sampTex,In.Tex0);
-
- //blend with vert color
- float4 clr=texclr*In.Color;
-
- //calc shiny mod
- float curDist=abs(tarDist-distance(In.Pos.xy,point.xy));
- float mod=1.0f;
- if (curDist<2.0)
- {
- mod=4.0f - curDist*2.0f;
- mod=1.0f + 0.5f*mod;
- }
-
- clr.xyz*=mod;
-
- //spit out color
- return clr;
- }
-